<!DOCTYPE html>
<html>
	<head lang="en">
		<meta charset="UTF-8">
		<title>课工场论坛列表</title>
		<link href="css/bbs.css" rel="stylesheet">
		<script src="../../js/jquery-3.4.1.min.js"></script>
		<script>
			 $(function(){
				 // $(".bbs header span").click(function(){
					// 	 $(".post").css("display","block"); 
				 // });
				 $('.bbs header span').on('click' ,function(){
					 $('.post').css('display','block');
				 })
				 $(".btn").click(function(){
					 let divTitle=$("#title").val();
					 let divSrc="images/tou0"+suiji()+".jpg";
					 let divSelect=$("#section").val();
					 let divContent=$(".content").val();
					 let date1=new Date();
					 $("#postList").prepend(`<li><div><img src="${divSrc}"></div><h1>${divTitle}</h1><p><span>版块：${divSelect}</span><span>发表时间：${date1.toLocaleString()}</span></p><p>${divContent}</p></li>`);
					//清空
					$("#title").val("");
					// $("#section").val("");
					$(".content").val("");
					 $(".post").css("display","none"); 
				 })
			 });
			 function suiji(){
				 return parseInt(Math.random()*3+1);
			 }
		</script>
	</head>
	<body>
		<div class="bbs">
			<header><span>我要发帖</span></header>
			<section>
				<ul id="postList">
					<li>
						<div><img src="images/tou02.jpg"></div>
						<h1>ggggg</h1>
						<p><span>版块：新手报到</span><span>发表时间：2019-11-18 17:28</span></p>
					</li>
					<li>
						<div>
							<img src="images/tou01.jpg"></div>
						<h1>ddddd</h1>
						<p><span>版块：新课来了</span><span>发表时间：2019-11-18 17:27</span></p>
					</li>
				</ul>
			</section>

			<div class="post">
				<input class="title" id="title" placeholder="请输入标题（1-50个字符）">
				所属版块：<select id="section">
					<option>请选择版块</option>
					<option>电子书籍</option>
					<option>新课来了</option>
					<option>新手报到</option>
					<option>职业规划</option>
				</select>
				<textarea class="content"></textarea>
				<input class="btn" value="发布">
			</div>
		</div>
	</body>
</html>
